﻿using System;
using System.Threading;
using System.Windows.Threading;

namespace RUBuildin.UnitTests
{
    internal static class UiThread
    {
        public static void Run(Action method)
        {
            var newWindowThread = new Thread(() =>
                {
                    method();
                    Dispatcher.Run();
                });

            newWindowThread.SetApartmentState(ApartmentState.STA);
            newWindowThread.IsBackground = true;
            newWindowThread.Start();

            newWindowThread.Join(TimeSpan.FromMinutes(5));
        }
    }
}